﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MangoCannon.Framework.Socket
{
    public class ClientManager
    {
        private static ClientManager mySelf = new ClientManager();

        public static ClientManager getIns()
        {
            if (null != mySelf)
            {
                return mySelf;
            }
            else
            {
                throw new Exception("No [ClientManager] Class Init!");
            }
        }

        ClientManager()
        {

        }

        private Dictionary<string,ClientHandle> CtClients = new Dictionary<string, ClientHandle>();

        public ClientHandle getHandle(string alias)
        {
            ClientHandle h = null;
            try
            {
                CtClients.TryGetValue(alias, out h);
            }
            catch (Exception)
            {
            }
            return h;
        }

        public void setHandle(string alias,ClientHandle h)
        {
            CtClients.Add(alias, h);
        }

        public void rmHandle(string alias)
        {
            try
            {
                CtClients.Remove(alias);
            }
            catch (Exception)
            {
            }
        }
    }
}
